home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Garbo
/
Garbo.cdr
/
mac
/
source
/
music4c.sit
/
Music4C Folder
/
orchestras
/
HoweExample1.c
next >
Wrap
Text File
|
1990-09-09
|
2KB
|
110 lines
/*
* ⌐ Graeme Gerrard 1990
* Faculty of Music, University of Melbourne
* Parkville Victoria 3052 Australia.
*
* ARPANET: grae@murdu.ucs.unimelb.edu.au
* telephone: (613) 344 4127, Fax: (613) 344 5346
*/
#include "Music4c.h"
#include <math.h>
#include "orch.h"
#include "ugens.h"
#define EXAMPLE1 1
#define MAXINS 6
#define NParams 13
static double *a;
static int i[MAXINS];
static long sampno;
extern FILE *ReportFile;
static long base;
/* Exponentially decaying waveform, from Howe, p232 */
void initl()
{
register long j;
a = (double *)NewPtr(MAXINS * NParams * sizeof(double));
for ( j = 0; j < MAXINS * NParams; j++ )
*(a+j) = 0.0;
}
void setup()
{
/*
* p4 = amp
* p5 = pitch (in 8ve.pc)
* p6 = number of waveform function
* p7 = location, as a number between 1 and 4
*
*/
switch(instype) {
case EXAMPLE1:
base = (insno * NParams) - NParams;
*(a+base) = p[4];
*(a+base+1) = p[4] * 0.1;
expset((a+base), (a+base+1), 1.5);
linset(0.01, p[3], 0.01, (a+base+2));
*(a+base+10) = pitch(p[5]);
*(a+base+12) = p[7] / 4.0;
i[insno-1] = (int)p[6];
break;
default:
/*fprintf(stderr, "error in instrument type number, %d\n", instype);*/
;
}
}
void orch()
{
register double sig;
switch(instype) {
case EXAMPLE1:
base = (insno * NParams) - NParams;
/* these calls are to the functions themselves
sig = expon((a+base), (a+base+1));
sig = linens(sig, (a+base+2));
sig = oscili(sig, *(a+base+10), i[insno-1], (a+base+11));
mono(sig*30000.);
*/
/* these are macro calls -
they are replaced on compilation by the definitions in ugens.h.
Saves the time of setting up all the function calls. Notice that
the phase itself is the argument to the oscils, not the address!
*/
Expon(sig, (a+base), (a+base+1));
Linens(sig, sig, (a+base+2));
Oscili(sig, sig, *(a+base+10), i[insno-1], *(a+base+11));
Mono(sig*30000);
/* Stereo(sig, 0.5);*/
/* Output(sig *0.15, sig *0.2, sig * 0.22, sig * 0.15);*/
break;
default:
fprintf(stderr, "error in instrument type number, %d\n", instype);
}
}
void ter()
{
/* This routine gets called at the END of each note
* (like setup gets called at the beginning) and can be
* useful for any clean up/file closure/statistics/reporting
* type things that you might want to do.
* Otherwise it just returns.
*/
}
void final()
{
/* called at the end of the synth run.
* close any files etc. you haven't already closed here.
*/
}